package pers.leeyns.rd.name;

import pers.leeyns.rd.en.RandomEnglishGenerator;
import pers.leeyns.rd.entity.EnStringModel;
import pers.leeyns.rd.utils.StringUtils;

/**
 * @description 英文名字随机生成
 * @author Leeyns
 * @date 2016年2月16日
 */
public class RandomEnNameGenerator extends RandomEnglishGenerator{
	/**
	 * 
	 */
	private static final long serialVersionUID = 2417291782998422660L;
	/**
	 * 姓氏 模板 50个  英文名字
	 */
	private final static String[]  FIRST_NAME_MODEL_ARRAYS = {"Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor", "Anderson", "Thomas", "Jackson", "White", "Harris", "Martin", "Thompson", "Garcia", "Martinez", "Robinson", "Clark", "Rodriguez", "Lewis", "Lee", "Walker", "Hall", "Allen", "Young", "Hernandez", "King", "Wright", "Lopez", "Hill", "Scott", "Green", "Adams", "Baker", "Gonzalez", "Nelson", "Carter", "Mitchell", "Perez", "Roberts", "Turner", "Phillips", "Campbell", "Parker", "Evans", "Edwards", "Collins"};
	
	public static synchronized RandomEnNameGenerator build(){
		return new RandomEnNameGenerator();
	}
	/**
	 * 随机生成英文名字的 “姓”，从传入的模板数组中获取
	 * @param firstNameArrs
	 * @return
	 */
	public String getRandomEnFirstName(String[] firstNameArrs){
		return firstNameArrs[this.nextInt(firstNameArrs.length)];
	}
	
	/**
	 * 随机生成英文名字的 “姓”，从预定模板中获取
	 * @return
	 */
	public String getRandomEnFirstNameByModel(){
		return getRandomEnFirstName(FIRST_NAME_MODEL_ARRAYS);
	}
	
	/**
	 * 随机生成英文名字的 “姓” 自动以26个字母组合
	 * @param number 生成的个数
	 * @return
	 */
	public String[] generatorRandomEnFirstName(int firstNameLength,int number){
		String[] str = new String[number];
		for(int i =0;i<number;i++){
			str[i] = generatorRandomEnFirstName(firstNameLength);
		}
		return str;
	}
	/**
	 * 随机生成英文名字的 “姓”，自动以26个字母组合
	 * @return
	 */
	public String generatorRandomEnFirstName(int firstNameLength){
		 return StringUtils.getFirstCharToUpper(getRandomEnString(firstNameLength, EnStringModel.EN_LOWER));
	}
	
	/**
	 * 随机生成英文名字的 “名”，自动以26个字母组合
	 * @param length 名字的长度
	 * @return
	 */
	public String getRandomEnSecondName(int length){
		return StringUtils.getFirstCharToUpper(getRandomEnString(length,EnStringModel.EN_LOWER));
	}
	
	/**
	 * 随机生成英文名字的 “名”，从预定模板中获取姓氏+随机字母组合的名
	 * @param secondNameLength 名的长度
	 * @return
	 */
	public String getRandomEnNameByModel(int secondNameLength){
		return getRandomEnFirstNameByModel()+" "+getRandomEnSecondName(secondNameLength);
	}
	
	/**
	 * 随机生成英文名字，随机姓+随机名
	 * @param firstNameLength “姓”字符串的长度
	 * @param secondNameLength “名”字符串的长度
	 * @return
	 */
	public String getRandomEnName(int firstNameLength,int secondNameLength){
		return generatorRandomEnFirstName(firstNameLength)+" "+getRandomEnSecondName(secondNameLength);
	}
	
	public static void main(String[] args) {
		RandomEnNameGenerator r = RandomEnNameGenerator.build();
		
		for(int t = 0;t < 100;t++){
			System.out.println(r.getRandomEnName(5, 6));
		}
		
		for(int t = 0;t < 100;t++){
			System.out.println(r.getRandomEnNameByModel(6));
		}
	}
}
    
 